﻿using Redis测试.testclass;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Redis测试
{
    class Program
    {
        static void Main(string[] args)
        {
            RedisHelper redis = new RedisHelper("192.168.10.147:6379");
            /*List<string> list = new List<string>();
            list.Add("1");
            list.Add("22");
            list.Add("333");
            redis.addList<string>("key1", list,1);
            Console.WriteLine("write ok");


            List<string> list2 = redis.getList<string>("key1",1);
            foreach (var str in list2) {
                Console.WriteLine(str);
            }*/

            DateTime startTime = DateTime.Now;

            Students students = new Students("niren",8,"zhuhai");
            redis.setObject("stu", students);
            double mSec = (DateTime.Now - startTime).TotalMilliseconds;
            Console.WriteLine("写入所用时间:{0} ms", mSec);
            startTime = DateTime.Now;
            Students obj = redis.getObject<Students>("stu");
            mSec = (DateTime.Now - startTime).TotalMilliseconds;
            Console.WriteLine("读出所用时间:{0} ms", mSec);

            Console.WriteLine("name = {0}", obj.Name);
            Console.WriteLine("age = {0}", obj.Age);
            Console.WriteLine("addr = {0}", obj.Addr);

            Console.WriteLine("read ok");
            Console.ReadKey();
        }
    }
}
